package me.ilvc.kotlinfandroid.ui.adapter

import android.support.v7.widget.RecyclerView
import android.view.ViewGroup
import android.widget.TextView
import me.ilvc.kotlinfandroid.domain.model.ForecastList

/**
 * @Author: iLvc
 * @Date：Create in 18:55 2017/9/12
 * @Description:
 */
class ForecastListAdapter(val weekForecast: ForecastList) :
        RecyclerView.Adapter<ForecastListAdapter.ViewHolder>() {
    override fun onCreateViewHolder(parent: ViewGroup, viewType:
    Int):
            ViewHolder? {
        return ViewHolder(TextView(parent.getContext()))
    }
    override fun onBindViewHolder(holder: ViewHolder,
                                  position: Int) {
        with(weekForecast.dailyForecast[position]) {
            holder.textView.text = "$date - $description - $high/$low"
        }
    }
    override fun getItemCount(): Int = weekForecast.dailyForecast.size
    class ViewHolder(val textView: TextView) : RecyclerView.ViewHolder(textView)
}
